package com.zzl.car.controller;


import com.github.pagehelper.PageInfo;
import com.zzl.car.entity.Notice;
import com.zzl.car.entity.Worker;
import com.zzl.car.mapper.ZzwWorkerMapper;
import com.zzl.car.service.ZzwWorkerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
public class ZzwWorkerController {
    @Autowired
    private ZzwWorkerService workerService;

    @GetMapping("/getWorker")
    public PageInfo<Worker> getWorker(@RequestParam(value = "name",required = false)String name,
                                      @RequestParam(value = "state",required = false)Integer state,
                                      @RequestParam(value = "currentPage",defaultValue = "1")int currentPage){

        return workerService.getWorker(name,state,currentPage);
    }

    /**
     * 按照id 删除员工信息 员工没有再其他表中出现
     * @param id
     * @return
     */
    @GetMapping("deleteWorker")
    public String deleteWorker(@RequestParam Integer id){
        return workerService.deleteWorker(id);
    }

    /**
     * 添加员工
     * @param worker
     * @return
     */
    @PostMapping("addWorker")
    public String addWorker(@RequestBody Worker worker){
        return workerService.addWorker(worker);
    }

    @PostMapping("modifyWorker")
    public String modifyWorker(@RequestBody Worker worker){
        return workerService.modifyWorker(worker);
    }

}
